//
// Created by zarra on 2017/2/9.
//

#ifndef QTEXTANALYZE_ANALYZECONTEXT_H
#define QTEXTANALYZE_ANALYZECONTEXT_H

#include "corecommon.h"
#include "Word.h"
#include "statement.h"
#include <map>

namespace TA {

    typedef QMap<QString, WordRawPtr> WordCache;

    class AnalyzeContext : public QObject {
    Q_OBJECT
    public:
        explicit AnalyzeContext(QObject *parent = 0);

    public:
        void appendStatement(const Statement* statement,int maxWordLength);
        void appendStatement(const StatementRawPtrArray& statements,int maxWordLength);
        Word* fetchWord(const QString& word,int begin);
        WordCache* getWordCache();

    private:
        WordCache wordCache;
        Document* doc;
    public:
        Document *getDoc() const;

        void setDoc(Document *doc);

    private:
        void appendStatementPrivate(const Statement* statement);
        void appendStatementChinese(const Statement* statement,int wordLength);
    };

}


#endif //QTEXTANALYZE_ANALYZECONTEXT_H
